package cn.cvs.service;

import cn.cvs.dao.StorageRecordMapper;
import cn.cvs.pojo.StorageRecord;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;
import java.util.Date;
import java.util.List;

@Transactional
@Service("StorageRecordServiceImpl")
public class StorageRecordServiceImpl implements StorageRecordService {

    @Resource
    private StorageRecordMapper storageRecordMapper;

    public StorageRecordServiceImpl() {
    }

    public List<StorageRecord> getList(String supName, Integer supplierId, Integer payStatus) throws Exception {
      /*  currentPageNo = (currentPageNo - 1) * pageSize;*/
        return this.storageRecordMapper.selectList(supName, supplierId, payStatus);
    }

    @Override
    public int add(StorageRecord storageRecord) throws Exception {
        return this.storageRecordMapper.add(storageRecord);
    }

     public int getCount(String supName, Integer supplierId, Integer payStatus) throws Exception {
        return this.storageRecordMapper.selectCount(supName, supplierId, payStatus);
    }


    public StorageRecord getById(Integer id) throws Exception {
        return this.storageRecordMapper.selectById(id);
    }

    public boolean update(StorageRecord storageRecord) throws Exception {
        boolean flag = false;
        storageRecord.setUpdatedTime(new Date());
        if (this.storageRecordMapper.update(storageRecord) > 0) {
            flag = true;
        }

        return flag;
    }

    public int  deleteById(Integer delId) throws Exception {
       return  this.storageRecordMapper.deleteById(delId);
    }
}
